#include <func.h>

int main(int argc,char *argv[])
{
    ARGS_CHECK(argc,2);
    int fd=open(argv[1],O_RDWR);
    ERROR_CHECK(fd,-1,"open");
    //printf message in the stdout
    printf("hello world\n");
    int newfd=10;  //record stdout's position
    dup2(STDOUT_FILENO,newfd);
    dup2(fd,STDOUT_FILENO);
    printf("hello world\n");  //this sentence print in the file
    dup2(newfd,STDOUT_FILENO);
    printf("come back\n");
    close(fd);
    return 0;
}

